<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">
  <meta http-equiv="Cache-Control" content="no-transform">
  <meta http-equiv="Cache-Control" content="no-siteapp">
  <meta name="msvalidate.01" content="3B3E06144BB6363961FBE583C9BA49E6">
  <meta name="baidu-site-verification" content="2IGNE9f4OxLiq11O">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-loading-bar.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"atan2021.gitee.io","root":"/","scheme":"Mist","version":"7.8.0","exturl":true,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":"default"},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":true,"color":"#222","save":"auto"},"fancybox":true,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="先说用到的软件和函数库 VS2017——我用VS2017社区版来开发，原因是软件免费而且好用，本项目用C++来做 opencv——Open Computer Vision是计算机视觉的库，有多种语言的接口，而且函数库也很丰富 dlib——Dlib是一个包含机器学习算法的C++开源工具包，提供大量的机器学习 &#x2F; 图像处理算法（网上看的 :-） ）本项目用的是VS2017社区版+opencv3.4.2">
<meta property="og:type" content="article">
<meta property="og:title" content="ARS展览项目（二）——环境搭建：opencv、dlib、VS2017">
<meta property="og:url" content="https://atan2021.gitee.io/2021/ARS%E5%B1%95%E8%A7%88%E9%A1%B9%E7%9B%AE%EF%BC%88%E4%BA%8C%EF%BC%89%E2%80%94%E2%80%94%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA%EF%BC%9Aopencv%E3%80%81dlib%E3%80%81VS2017/index.html">
<meta property="og:site_name" content="博客">
<meta property="og:description" content="先说用到的软件和函数库 VS2017——我用VS2017社区版来开发，原因是软件免费而且好用，本项目用C++来做 opencv——Open Computer Vision是计算机视觉的库，有多种语言的接口，而且函数库也很丰富 dlib——Dlib是一个包含机器学习算法的C++开源工具包，提供大量的机器学习 &#x2F; 图像处理算法（网上看的 :-） ）本项目用的是VS2017社区版+opencv3.4.2">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-09-05T09:04:47.000Z">
<meta property="article:modified_time" content="2022-01-23T12:29:26.041Z">
<meta property="article:author" content="陈政任">
<meta property="article:tag" content="ARS项目">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://atan2021.gitee.io/2021/ARS%E5%B1%95%E8%A7%88%E9%A1%B9%E7%9B%AE%EF%BC%88%E4%BA%8C%EF%BC%89%E2%80%94%E2%80%94%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA%EF%BC%9Aopencv%E3%80%81dlib%E3%80%81VS2017/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>ARS展览项目（二）——环境搭建：opencv、dlib、VS2017 | 博客</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">博客</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>所有博客</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <a role="button" class="book-mark-link book-mark-link-fixed"></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://atan2021.gitee.io/2021/ARS%E5%B1%95%E8%A7%88%E9%A1%B9%E7%9B%AE%EF%BC%88%E4%BA%8C%EF%BC%89%E2%80%94%E2%80%94%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA%EF%BC%9Aopencv%E3%80%81dlib%E3%80%81VS2017/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="陈政任">
      <meta itemprop="description" content="what atan">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="博客">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          ARS展览项目（二）——环境搭建：opencv、dlib、VS2017
        </h1>

        <div class="post-meta">

	  
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-09-05 17:04:47" itemprop="dateCreated datePublished" datetime="2021-09-05T17:04:47+08:00">2021-09-05</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-01-23 20:29:26" itemprop="dateModified" datetime="2022-01-23T20:29:26+08:00">2022-01-23</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/ARS%E9%A1%B9%E7%9B%AE/" itemprop="url" rel="index"><span itemprop="name">ARS项目</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="先说用到的软件和函数库"><a href="#先说用到的软件和函数库" class="headerlink" title="先说用到的软件和函数库"></a>先说用到的软件和函数库</h1><ul>
<li>VS2017——我用VS2017社区版来开发，原因是软件免费而且好用，本项目用C++来做</li>
<li>opencv——Open Computer Vision是计算机视觉的库，有多种语言的接口，而且函数库也很丰富</li>
<li>dlib——Dlib是一个包含机器学习算法的C++开源工具包，提供大量的机器学习 / 图像处理算法（网上看的 :-） ）<br>本项目用的是VS2017社区版+opencv3.4.2版本+dlib9.0.3 。用其它版本也可以，新一点的版本吧。<span id="more"></span>
</li>
</ul>
<h1 id="容易遇到的问题"><a href="#容易遇到的问题" class="headerlink" title="容易遇到的问题"></a>容易遇到的问题</h1><ol>
<li>dlib 配置的时候是需要release|x64 的模式,因为debug模式会让程序运行得非常缓慢，这在dlib官网上有说明<span class="exturl" data-url="aHR0cDovL2RsaWIubmV0L2ZhcS5odG1sI1doeWlzZGxpYnNsb3c=">http://dlib.net/faq.html#Whyisdlibslow<i class="fa fa-external-link-alt"></i></span></li>
</ol>
<h1 id="opencv-在-VS2017-里面的配置"><a href="#opencv-在-VS2017-里面的配置" class="headerlink" title="opencv 在 VS2017 里面的配置"></a>opencv 在 VS2017 里面的配置</h1><p>关于opencv的配置，这个文档已经非常清楚了，<span class="exturl" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQxMTc1OTA1L2FydGljbGUvZGV0YWlscy84MDU2MDQyOQ==">https://blog.csdn.net/qq_41175905/article/details/80560429<i class="fa fa-external-link-alt"></i></span>，非常感谢这位作者的帮助。如果看不懂，多找几篇关于配置的来看，方法都一样，只是详细与否的区别。<br><strong>总结是：</strong></p>
<ol>
<li>比如把opencv安装在了D:\opencv342\ ，安装好后</li>
<li>右键“我的电脑”-&gt;属性-&gt;高级系统设置-&gt;环境变量，在后面添加环境变量： D:\opencv342\opencv\build\x64\vc15\bin</li>
<li>配置好环境变量后，打开VS2017，新建一个C++空项目</li>
<li>打开属性管理器，菜单栏-&gt;视图-&gt;其他窗口-&gt;属性管理器，对release|X64进行配置：右键release|X64-&gt;新建一个属性表，重命名为opencv</li>
<li>双击opencv属性表，属性中的 VC++目录-&gt;包含目录<br>D:\opencv342\opencv\build\include<br>D:\opencv342\opencv\build\include\opencv<br>D:\opencv342\opencv\build\include\opencv2</li>
<li>VC++目录-&gt;库目录<br>D:\opencv342\opencv\build\x64\vc15\lib</li>
<li>链接器-&gt;输入-&gt;附加依赖项中加入<br>opencv_world341d.lib</li>
<li>到这里，opencv就配置好了，第2步时配置环境变量的重点，第5、6、7步是配置vs的重点，第8步可有可无，只是为了未来方便。就是打开第3步的项目文件夹，把刚刚配置好的那个新建的opencv属性表保存在另外一个容易保存的地方就好，到时候要用就把它导入进来，就不用重新配置了。</li>
</ol>
<p><strong>配置好后测试一下：</strong></p>
<ol>
<li>新建一个C++空项目</li>
<li>打开属性管理表，右键release|X64，添加-&gt;现有项，然后把刚刚的opencv属性表导入进去</li>
<li>然后转到解决方案的管理器，右键源文件-&gt;添加新建项，然后添加一个cpp文件，比如是1.cpp</li>
<li>然后把下面的代码粘贴进去</li>
</ol>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;opencv2/core.hpp&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;opencv2/imgproc.hpp&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;opencv2/highgui.hpp&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&quot;opencv2/videoio.hpp&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"> </span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> cv;</span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"> </span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    cout &lt;&lt; <span class="string">&quot;Built with OpenCV &quot;</span> &lt;&lt; CV_VERSION &lt;&lt; endl;</span><br><span class="line"> </span><br><span class="line">	<span class="function">VideoCapture <span class="title">capture</span><span class="params">(<span class="number">0</span>)</span></span>;    <span class="comment">// 打开摄像头</span></span><br><span class="line">	<span class="keyword">if</span>(!capture.<span class="built_in">isOpened</span>())    <span class="comment">// 判断是否打开成功</span></span><br><span class="line">	&#123;</span><br><span class="line">		cout &lt;&lt; <span class="string">&quot;open camera failed. &quot;</span> &lt;&lt; endl;</span><br><span class="line">		<span class="keyword">return</span> <span class="number">-1</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="keyword">while</span>(<span class="literal">true</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		Mat frame;</span><br><span class="line">		capture &gt;&gt; frame;    <span class="comment">// 读取图像帧至frame</span></span><br><span class="line">		<span class="keyword">if</span>(!frame.<span class="built_in">empty</span>())	<span class="comment">// 判断是否为空</span></span><br><span class="line">		&#123;</span><br><span class="line">			<span class="built_in">imshow</span>(<span class="string">&quot;camera&quot;</span>, frame);</span><br><span class="line">		&#125;</span><br><span class="line">		</span><br><span class="line">		<span class="keyword">if</span>(<span class="built_in">waitKey</span>(<span class="number">30</span>) &gt; <span class="number">0</span>)		<span class="comment">// delay 30 ms等待按键</span></span><br><span class="line">		&#123;</span><br><span class="line">			<span class="keyword">break</span>;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line"> </span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ol>
<li>这个代码的意思是打开笔记本电脑自带的摄像头，要是没有摄像头的话要借一个usb摄像头，然后把代码里的 <code>VideoCapture capture(0);</code> 改成 <code>VideoCapture capture(1);</code>，就可以打开usb摄像头。</li>
<li>如果可以，那么opencv的配置就成功了。</li>
</ol>
<h1 id="dlib-在-VS2017-里面的配置"><a href="#dlib-在-VS2017-里面的配置" class="headerlink" title="dlib 在 VS2017 里面的配置"></a>dlib 在 VS2017 里面的配置</h1><p>关于dlib的配置，这个文档，<span class="exturl" data-url="aHR0cHM6Ly93d3cuY25ibG9ncy5jb20vZGFwZW5nLWJ1cHQvcC83ODA3Njc5Lmh0bWw=">https://www.cnblogs.com/dapeng-bupt/p/7807679.html<i class="fa fa-external-link-alt"></i></span>和这个文档<span class="exturl" data-url="aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2N6cDE5OTQwMjIzL2FydGljbGUvZGV0YWlscy83ODU3NzU3MA==">https://blog.csdn.net/czp19940223/article/details/78577570<i class="fa fa-external-link-alt"></i></span>，啊也非常感谢这两位作者的帮助。<br><strong>具体就是：</strong></p>
<ol>
<li>下载并且解压安装包</li>
<li>cmake 编译dlib （这是为了得到dlib.lib）(比如编译报存的文件夹是D:\dlib-9.0.3\dlibmake)</li>
<li>打开vs，打开刚刚cmake编译的dlib项目，然后用release x64来重新编译dlib</li>
<li>然后新建空项目，然后release|x64 新建属性表</li>
<li>VC++目录-&gt;包含目录，把dlib刚开始解压的目录写进去（比如D:\dlib-9.0.3）</li>
<li>VC++目录-&gt;库目录，把刚刚生成的lib目录放进去(比如D:\dlib-9.0.3\dlibmake\release)</li>
<li>链接器-&gt;输入-&gt;附加依赖项，加入dlib.lib （如果不是这个名字就改成你文件夹里的那个lib的名字）</li>
<li>把属性表保存好</li>
</ol>
<p><strong>配置好后测试一下：</strong></p>
<ol>
<li>新建空项目，release|x64 导入刚刚的属性表</li>
<li>在源文件那里，新建一个cpp源文件</li>
<li>写入下面的代码</li>
<li>把这里的代码复制进去运行，（这位作者的代码）<span class="exturl" data-url="aHR0cDovL2RsaWIubmV0L2d1aV9hcGlfZXguY3BwLmh0bWw=">http://dlib.net/gui_api_ex.cpp.html<i class="fa fa-external-link-alt"></i></span>，如果可以运行就行了。</li>
<li>为了方便也贴在下面，但是比较多</li>
</ol>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt</span></span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">    This is an example illustrating the use of the gui api from the dlib C++ Library.</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">    This is a pretty simple example.  It makes a window with a user</span></span><br><span class="line"><span class="comment">    defined widget (a draggable colored box) and a button.  You can drag the</span></span><br><span class="line"><span class="comment">    box around or click the button which increments a counter. </span></span><br><span class="line"><span class="comment">*/</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;dlib/gui_widgets.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;sstream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string&gt;</span></span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> std;</span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> dlib;</span><br><span class="line"></span><br><span class="line"><span class="comment">//  ----------------------------------------------------------------------------</span></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">color_box</span> :</span> <span class="keyword">public</span> draggable </span><br><span class="line">&#123;</span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">        Here I am defining a custom drawable widget that is a colored box that</span></span><br><span class="line"><span class="comment">        you can drag around on the screen.  draggable is a special kind of drawable</span></span><br><span class="line"><span class="comment">        object that, as the name implies, is draggable by the user via the mouse.</span></span><br><span class="line"><span class="comment">        To make my color_box draggable all I need to do is inherit from draggable.</span></span><br><span class="line"><span class="comment">    */</span></span><br><span class="line">    <span class="keyword">unsigned</span> <span class="keyword">char</span> red, green,blue;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line">    <span class="built_in">color_box</span> (</span><br><span class="line">        drawable_window&amp; w,</span><br><span class="line">        rectangle area,</span><br><span class="line">        <span class="keyword">unsigned</span> <span class="keyword">char</span> red_,</span><br><span class="line">        <span class="keyword">unsigned</span> <span class="keyword">char</span> green_,</span><br><span class="line">        <span class="keyword">unsigned</span> <span class="keyword">char</span> blue_</span><br><span class="line">    ) :</span><br><span class="line">        <span class="built_in">draggable</span>(w),</span><br><span class="line">        <span class="built_in">red</span>(red_),</span><br><span class="line">        <span class="built_in">green</span>(green_),</span><br><span class="line">        <span class="built_in">blue</span>(blue_)</span><br><span class="line">    &#123;</span><br><span class="line">        rect = area;</span><br><span class="line">        <span class="built_in">set_draggable_area</span>(<span class="built_in">rectangle</span>(<span class="number">10</span>,<span class="number">10</span>,<span class="number">400</span>,<span class="number">400</span>));</span><br><span class="line">        </span><br><span class="line">        <span class="comment">// Whenever you make your own drawable widget (or inherit from any drawable widget </span></span><br><span class="line">        <span class="comment">// or interface such as draggable) you have to remember to call this function to </span></span><br><span class="line">        <span class="comment">// enable the events.  The idea here is that you can perform whatever setup you </span></span><br><span class="line">        <span class="comment">// need to do to get your object into a valid state without needing to worry about </span></span><br><span class="line">        <span class="comment">// event handlers triggering before you are ready.</span></span><br><span class="line">        <span class="built_in">enable_events</span>();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    ~<span class="built_in">color_box</span> (</span><br><span class="line">    )</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="comment">// Disable all further events for this drawable object.  We have to do this </span></span><br><span class="line">        <span class="comment">// because we don&#x27;t want any events (like draw()) coming to this object while or </span></span><br><span class="line">        <span class="comment">// after it has been destructed.</span></span><br><span class="line">        <span class="built_in">disable_events</span>();</span><br><span class="line">        </span><br><span class="line">        <span class="comment">// Tell the parent window to redraw its area that previously contained this</span></span><br><span class="line">        <span class="comment">// drawable object.</span></span><br><span class="line">        parent.<span class="built_in">invalidate_rectangle</span>(rect);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">private</span>:</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">void</span> <span class="title">draw</span> <span class="params">(</span></span></span><br><span class="line"><span class="params"><span class="function">        <span class="keyword">const</span> canvas&amp; c</span></span></span><br><span class="line"><span class="params"><span class="function">    )</span> <span class="keyword">const</span></span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="comment">// The canvas is an object that represents a part of the parent window</span></span><br><span class="line">        <span class="comment">// that needs to be redrawn.  </span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// The first thing I usually do is check if the draw call is for part</span></span><br><span class="line">        <span class="comment">// of the window that overlaps with my widget.  We don&#x27;t have to do this </span></span><br><span class="line">        <span class="comment">// but it is usually good to do as a speed hack.  Also, the reason</span></span><br><span class="line">        <span class="comment">// I don&#x27;t have it set to only give you draw calls when it does indeed</span></span><br><span class="line">        <span class="comment">// overlap is because you might want to do some drawing outside of your</span></span><br><span class="line">        <span class="comment">// widget&#x27;s rectangle.  But usually you don&#x27;t want to do that :)</span></span><br><span class="line">        rectangle area = c.<span class="built_in">intersect</span>(rect);</span><br><span class="line">        <span class="keyword">if</span> (area.<span class="built_in">is_empty</span>() == <span class="literal">true</span>)</span><br><span class="line">            <span class="keyword">return</span>;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// This simple widget is just going to draw a box on the screen.   </span></span><br><span class="line">        <span class="built_in">fill_rect</span>(c,rect,<span class="built_in">rgb_pixel</span>(red,green,blue));</span><br><span class="line">    &#125;</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="comment">//  ----------------------------------------------------------------------------</span></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">win</span> :</span> <span class="keyword">public</span> drawable_window </span><br><span class="line">&#123;</span><br><span class="line">    <span class="comment">/*</span></span><br><span class="line"><span class="comment">        Here I am going to define our window.  In general, you can define as </span></span><br><span class="line"><span class="comment">        many window types as you like and make as many instances of them as you want.</span></span><br><span class="line"><span class="comment">        In this example I am only making one though.</span></span><br><span class="line"><span class="comment">    */</span></span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line">    <span class="built_in">win</span>(</span><br><span class="line">    ) : <span class="comment">// All widgets take their parent window as an argument to their constructor.</span></span><br><span class="line">        <span class="built_in">c</span>(*<span class="keyword">this</span>),</span><br><span class="line">        <span class="built_in">b</span>(*<span class="keyword">this</span>),</span><br><span class="line">        <span class="built_in">cb</span>(*<span class="keyword">this</span>,<span class="built_in">rectangle</span>(<span class="number">100</span>,<span class="number">100</span>,<span class="number">200</span>,<span class="number">200</span>),<span class="number">0</span>,<span class="number">0</span>,<span class="number">255</span>), <span class="comment">// the color_box will be blue and 101 pixels wide and tall</span></span><br><span class="line">        <span class="built_in">mbar</span>(*<span class="keyword">this</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="comment">// tell our button to put itself at the position (10,60). </span></span><br><span class="line">        b.<span class="built_in">set_pos</span>(<span class="number">10</span>,<span class="number">60</span>);</span><br><span class="line">        b.<span class="built_in">set_name</span>(<span class="string">&quot;button&quot;</span>);</span><br><span class="line"></span><br><span class="line">        <span class="comment">// let&#x27;s put the label 5 pixels below the button</span></span><br><span class="line">        c.<span class="built_in">set_pos</span>(b.<span class="built_in">left</span>(),b.<span class="built_in">bottom</span>()+<span class="number">5</span>);</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        <span class="comment">// set which function should get called when the button gets clicked.  In this case we want</span></span><br><span class="line">        <span class="comment">// the on_button_clicked member to be called on *this.</span></span><br><span class="line">        b.<span class="built_in">set_click_handler</span>(*<span class="keyword">this</span>,&amp;win::on_button_clicked);</span><br><span class="line">        <span class="comment">// Alternatively, if you have a compiler which supports the lambda functions from the</span></span><br><span class="line">        <span class="comment">// new C++ standard then you can use a lambda function instead of telling the click</span></span><br><span class="line">        <span class="comment">// handler to call one of the member functions.  So for example, you could do this</span></span><br><span class="line">        <span class="comment">// instead (uncomment the code if you have C++0x support):</span></span><br><span class="line">        <span class="comment">/*</span></span><br><span class="line"><span class="comment">        b.set_click_handler([&amp;]()&#123;</span></span><br><span class="line"><span class="comment">                ++counter;</span></span><br><span class="line"><span class="comment">                ostringstream sout;</span></span><br><span class="line"><span class="comment">                sout &lt;&lt; &quot;Counter: &quot; &lt;&lt; counter;</span></span><br><span class="line"><span class="comment">                c.set_text(sout.str());</span></span><br><span class="line"><span class="comment">                &#125;);</span></span><br><span class="line"><span class="comment">        */</span></span><br><span class="line">        <span class="comment">// In general, all the functions which register events can take either member </span></span><br><span class="line">        <span class="comment">// functions or lambda functions.</span></span><br><span class="line"></span><br><span class="line">        </span><br><span class="line">        <span class="comment">// Let&#x27;s also make a simple menu bar.  </span></span><br><span class="line">        <span class="comment">// First we say how many menus we want in our menu bar.  In this example we only want 1.</span></span><br><span class="line">        mbar.<span class="built_in">set_number_of_menus</span>(<span class="number">1</span>);</span><br><span class="line">        <span class="comment">// Now we set the name of our menu.  The &#x27;M&#x27; means that the M in Menu will be underlined</span></span><br><span class="line">        <span class="comment">// and the user will be able to select it by hitting alt+M</span></span><br><span class="line">        mbar.<span class="built_in">set_menu_name</span>(<span class="number">0</span>,<span class="string">&quot;Menu&quot;</span>,<span class="string">&#x27;M&#x27;</span>);</span><br><span class="line"></span><br><span class="line">        <span class="comment">// Now we add some items to the menu.  Note that items in a menu are listed in the</span></span><br><span class="line">        <span class="comment">// order in which they were added.</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// First let&#x27;s make a menu item that does the same thing as our button does when it is clicked.</span></span><br><span class="line">        <span class="comment">// Again, the &#x27;C&#x27; means the C in Click is underlined in the menu. </span></span><br><span class="line">        mbar.<span class="built_in">menu</span>(<span class="number">0</span>).<span class="built_in">add_menu_item</span>(<span class="built_in">menu_item_text</span>(<span class="string">&quot;Click Button!&quot;</span>,*<span class="keyword">this</span>,&amp;win::on_button_clicked,<span class="string">&#x27;C&#x27;</span>));</span><br><span class="line">        <span class="comment">// let&#x27;s add a separator (i.e. a horizontal separating line) to the menu</span></span><br><span class="line">        mbar.<span class="built_in">menu</span>(<span class="number">0</span>).<span class="built_in">add_menu_item</span>(<span class="built_in">menu_item_separator</span>());</span><br><span class="line">        <span class="comment">// Now let&#x27;s make a menu item that calls show_about when the user selects it.  </span></span><br><span class="line">        mbar.<span class="built_in">menu</span>(<span class="number">0</span>).<span class="built_in">add_menu_item</span>(<span class="built_in">menu_item_text</span>(<span class="string">&quot;About&quot;</span>,*<span class="keyword">this</span>,&amp;win::show_about,<span class="string">&#x27;A&#x27;</span>));</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        <span class="comment">// set the size of this window</span></span><br><span class="line">        <span class="built_in">set_size</span>(<span class="number">430</span>,<span class="number">380</span>);</span><br><span class="line"></span><br><span class="line">        counter = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">        <span class="built_in">set_title</span>(<span class="string">&quot;dlib gui example&quot;</span>);</span><br><span class="line">        <span class="built_in">show</span>();</span><br><span class="line">    &#125; </span><br><span class="line"></span><br><span class="line">    ~<span class="built_in">win</span>(</span><br><span class="line">    )</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="comment">// You should always call close_window() in the destructor of window</span></span><br><span class="line">        <span class="comment">// objects to ensure that no events will be sent to this window while </span></span><br><span class="line">        <span class="comment">// it is being destructed.  </span></span><br><span class="line">        <span class="built_in">close_window</span>();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">private</span>:</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">void</span> <span class="title">on_button_clicked</span> <span class="params">(</span></span></span><br><span class="line"><span class="params"><span class="function">    )</span></span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="comment">// when someone clicks our button it will increment the counter and </span></span><br><span class="line">        <span class="comment">// display it in our label c.</span></span><br><span class="line">        ++counter;</span><br><span class="line">        ostringstream sout;</span><br><span class="line">        sout &lt;&lt; <span class="string">&quot;counter: &quot;</span> &lt;&lt; counter;</span><br><span class="line">        c.<span class="built_in">set_text</span>(sout.<span class="built_in">str</span>());</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">void</span> <span class="title">show_about</span><span class="params">(</span></span></span><br><span class="line"><span class="params"><span class="function">    )</span></span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="built_in">message_box</span>(<span class="string">&quot;About&quot;</span>,<span class="string">&quot;This is a dlib gui example program&quot;</span>);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">unsigned</span> <span class="keyword">long</span> counter;</span><br><span class="line">    label c;</span><br><span class="line">    button b;</span><br><span class="line">    color_box cb;</span><br><span class="line">    menu_bar mbar;</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="comment">//  ----------------------------------------------------------------------------</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">// create our window</span></span><br><span class="line">    win my_window;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">// wait until the user closes this window before we let the program </span></span><br><span class="line">    <span class="comment">// terminate.</span></span><br><span class="line">    my_window.<span class="built_in">wait_until_closed</span>();</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//  ----------------------------------------------------------------------------</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// Normally, if you built this application on MS Windows in Visual Studio you</span></span><br><span class="line"><span class="comment">// would see a black console window pop up when you ran it.  The following</span></span><br><span class="line"><span class="comment">// #pragma directives tell Visual Studio to not include a console window along</span></span><br><span class="line"><span class="comment">// with your application.  However, if you prefer to have the console pop up as</span></span><br><span class="line"><span class="comment">// well then simply remove these #pragma statements.</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">ifdef</span> _MSC_VER</span></span><br><span class="line"><span class="meta">#   <span class="meta-keyword">pragma</span> comment( linker, <span class="meta-string">&quot;/entry:mainCRTStartup&quot;</span> )</span></span><br><span class="line"><span class="meta">#   <span class="meta-keyword">pragma</span> comment( linker, <span class="meta-string">&quot;/SUBSYSTEM:WINDOWS&quot;</span> )</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line"></span><br><span class="line"><span class="comment">//  ----------------------------------------------------------------------------</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>
    </div>

    
    
    

      
      <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">------ 本文结束------</div>
    
</div>
      
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>陈政任
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://atan2021.gitee.io/2021/ARS%E5%B1%95%E8%A7%88%E9%A1%B9%E7%9B%AE%EF%BC%88%E4%BA%8C%EF%BC%89%E2%80%94%E2%80%94%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA%EF%BC%9Aopencv%E3%80%81dlib%E3%80%81VS2017/" title="ARS展览项目（二）——环境搭建：opencv、dlib、VS2017">https://atan2021.gitee.io/2021/ARS展览项目（二）——环境搭建：opencv、dlib、VS2017/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <span class="exturl" data-url="aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzQuMC8="><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</span> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/ARS%E9%A1%B9%E7%9B%AE/" rel="tag"><i class="fa fa-tag"></i> ARS项目</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/ARS%E5%B1%95%E8%A7%88%E9%A1%B9%E7%9B%AE%EF%BC%88%E4%B8%80%EF%BC%89%E2%80%94%E2%80%94%E5%89%8D%E8%A8%80/" rel="prev" title="ARS展览项目（一）——前言">
      <i class="fa fa-chevron-left"></i> ARS展览项目（一）——前言
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/ARS%E5%B1%95%E8%A7%88%E9%A1%B9%E7%9B%AE%EF%BC%88%E4%B8%89%EF%BC%89%E2%80%94%E2%80%94%E8%AF%86%E5%88%AB%E9%9D%A2%E9%83%A8%E5%BE%97%E5%88%B0%E7%89%B9%E5%BE%81%E7%82%B9/" rel="next" title="ARS展览项目（三）——识别面部得到特征点">
      ARS展览项目（三）——识别面部得到特征点 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%85%88%E8%AF%B4%E7%94%A8%E5%88%B0%E7%9A%84%E8%BD%AF%E4%BB%B6%E5%92%8C%E5%87%BD%E6%95%B0%E5%BA%93"><span class="nav-number">1.</span> <span class="nav-text">先说用到的软件和函数库</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%AE%B9%E6%98%93%E9%81%87%E5%88%B0%E7%9A%84%E9%97%AE%E9%A2%98"><span class="nav-number">2.</span> <span class="nav-text">容易遇到的问题</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#opencv-%E5%9C%A8-VS2017-%E9%87%8C%E9%9D%A2%E7%9A%84%E9%85%8D%E7%BD%AE"><span class="nav-number">3.</span> <span class="nav-text">opencv 在 VS2017 里面的配置</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#dlib-%E5%9C%A8-VS2017-%E9%87%8C%E9%9D%A2%E7%9A%84%E9%85%8D%E7%BD%AE"><span class="nav-number">4.</span> <span class="nav-text">dlib 在 VS2017 里面的配置</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="陈政任"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">陈政任</p>
  <div class="site-description" itemprop="description">what atan</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">14</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">5</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">5</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">陈政任</span>
</div>
  <div class="powered-by">由 <span class="exturl theme-link" data-url="aHR0cHM6Ly9oZXhvLmlv">Hexo</span> & <span class="exturl theme-link" data-url="aHR0cHM6Ly9taXN0LnRoZW1lLW5leHQub3Jn">NexT.Mist</span> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
  <script src="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>

<script src="/js/bookmark.js"></script>




  
  <script>
    (function(){
      var canonicalURL, curProtocol;
      //Get the <link> tag
      var x=document.getElementsByTagName("link");
		//Find the last canonical URL
		if(x.length > 0){
			for (i=0;i<x.length;i++){
				if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
					canonicalURL=x[i].href;
				}
			}
		}
    //Get protocol
	    if (!canonicalURL){
	    	curProtocol = window.location.protocol.split(':')[0];
	    }
	    else{
	    	curProtocol = canonicalURL.split(':')[0];
	    }
      //Get current URL if the canonical URL does not exist
	    if (!canonicalURL) canonicalURL = window.location.href;
	    //Assign script content. Replace current URL with the canonical URL
      !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
  </script>




  
<script src="/js/local-search.js"></script>













  

  

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","model":{"jsonPath":"/live2dw/assets/tororo.model.json"},"display":{"position":"right","width":180,"height":360},"mobile":{"show":false},"react":{"opacityDefault":1,"opacityOnHover":1},"log":false,"tagMode":false});</script></body>
</html>
